<template>
  <div class="notice" v-if="visible">
    <div style="display: flex;align-items: center;">
      <div class="pop-head">
        <Icon type="md-notifications" color="#FF186B" size="32" />
        <span class="head-title">{{ message.subject }}</span>
      </div>
      <Icon type="ios-close" size="32" />
    </div>
    <div class="pop-body">
      <img :src="message.messageImg" class="pop-img" alt="">
      <span v-html="message.messageText"></span>
    </div>
    <div class="pop-bottom">
      <Button @click="visible = false">{{ $t("home.know_text") }}</Button>
      <Button type="primary" @click="handleBtn(message.messageType)">{{ $t("home.handle_text") }}</Button>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      visible: false,
      message: {},
    };
  },
  methods: {
    showNotice(message) {
      this.message = message;
      this.visible = true;
    },
    handleBtn(val) {
      // 1订单2仓库3运单
      if (val == 1) {
        this.visible = false;
        this.$router.push({
          name: 'order',
          params: {
            orderNo: this.message.orderNo
          }
        })
      } else if (val == 2) {
        this.visible = false;
        this.$router.push({
          name: 'warehouse',
          params: {
            orderNo: this.message.orderNo
          }
        })
      } else if (val == 3) {
        this.visible = false;
        this.$router.push({
          name: 'shipment',
          params: {
            orderNo: this.message.receiverId
          }
        })
      }
    }
  },
};
</script>

<style lang="less" scoped>
.notice {
  width: 434px;
  position: fixed;
  top: 20px;
  right: 20px;
  background: #FFFFFF;
  color: white;
  padding: 10px;
  border-radius: 5px;
  animation: fadeIn 2s ease-in-out forwards;
  z-index: 9999;
  box-shadow: 10px 10px 20px #8080804f;

  .pop-head {
    font-family: PingFang HK, PingFang HK;
    font-weight: 600;
    font-size: 16px;
    color: #000000;
    line-height: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
  }

  .pop-body {
    font-family: PingFang HK, PingFang HK;
    font-weight: 400;
    font-size: 14px;
    color: #333333;
    line-height: 16px;
    display: inline-flex;
    gap: 12px;
    margin-top: 12px;

    .pop-img {
      width: 44px;
      height: 44px;
      border-radius: 4px 4px 4px 4px;
    }

    span {
      width: 350px;
      overflow-wrap: break-word;
    }
  }

  .pop-bottom {
    display: flex;
    justify-content: end;
    gap: 24px;
    margin-top: 12px;
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}
</style>